//
// Created by 下次一定 on 2021/9/4.
//


#include<iostream>

using namespace std;


const int N = 1010;
int arr[N][N];
int prefixSum[N][N];
int n;

int main() {
    scanf("%d", &n);

    int count = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            arr[i][j] = count++;
            //前缀和
            prefixSum[i + 1][j + 1] = prefixSum[i + 1][j] + prefixSum[i][j + 1] - prefixSum[i][j] + arr[i][j];
        }

    //部分和
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &x2, &y1, &y2);
    printf("%d", prefixSum[x2][y2] - prefixSum[x1-1][y2] - prefixSum[x2][y1-1] + prefixSum[x1 -1][y1-1]);

}
